package com.ctvit.sjk.knowledge.model.pojo.vo;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ctvit.sjk.knowledge.model.pojo.domain.TabModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 模型VO
 *
 * @author heyingcheng
 * @date 2025/03/24
 */
@Getter
@Setter
@ToString
public class ModelViewVO {

    protected String id;

    protected String name;

    protected String provider;

    @JsonProperty("model_type")
    protected String modelType;

    @JsonProperty("model_name")
    protected String modelName;

    @JsonProperty("permission_type")
    protected String permissionType;

    @JsonProperty("model_params_form")
    protected JSONArray modelParamsForm;

    protected JSONObject credential;

    protected String status;

    protected JSONObject meta;

    @JsonProperty("user_id")
    protected String userId;

    @JsonProperty("username")
    protected String userName;

    public ModelViewVO(TabModel entity) {
        this.assign(entity);
    }

    public void assign(TabModel entity) {
        this.setId(entity.getModelId());
        this.setName(entity.getModelName());
        this.setProvider(entity.getProviderCode());
        this.setModelName(entity.getProviderModel());
        this.setModelType(entity.getModelType());
        this.setPermissionType(entity.getPermissionType());
        this.setModelParamsForm(JSON.parseArray(entity.getModelParamsForm()));
        this.setCredential(JSON.parseObject(entity.getCredential()));
        this.setStatus(entity.getModelStatus());
        this.setMeta(JSON.parseObject(entity.getMetadata()));
        this.setUserId(entity.getCreateId());
        this.setUserName(entity.getCreateId());
    }

}
